perm filename PACWAR.JDH[UP,DOC] blob
sn#741620 filedate 1984-02-05 generic text, type C, neo UTF8
COMMENT ⊗ VALID 00006 PAGES
C REC PAGE DESCRIPTION
C00001 00001
C00002 00002 Introduction
C00014 00003 Program control etc.
C00018 00004 Creating and destroying PAC-mites
C00024 00005 Display control
C00028 00006 Input and output
C00036 ENDMK
C⊗;
Introduction
The PACWAR program simulates PAC-LAND, the two-dimensional rasterized
universe invented for CS204 Autumn quarter, 1982. The material on this
page was copied from STAN-CS-83-990 pp50--61. A detailed discussion of
PAC-LAND can be found in that report.
The laws of physics/chemistry/biology/everything in PAC-land are fairly
simple, and they can be described precisely as follows:
(1) PAC-land consists entirely of discrete sites at positions m+ni
of the complex plane, where m and n are arbitrary integers.
(2) Each site is occupied by either a barrier (denoted ≡),
by a blob (denoted .), or by a PAC-mite.
(3) A PAC-mite can exist in any of four directions (pointing right, up,
left, or down), which we shall call 0, 1, 2, 3; and it can have either
0, 1, 2, or 3 teeth, independent of its direction. Thus, there are
sixteen possible states. It is convenient to allow the direction to be
any integer and then to reduce it modulo 4, so that, e.g., direction 13
is the same as direction 1.
(4) A PAC-mite of direction d in site s=m+ni is said to be aiming at
site s+i↑d. Up to four PAC-mites can therefore be aiming simultaneously
at the same site.
(5) Mites with more teeth have a more powerful bite; we say that a PAC-mite
attacks site s if it aims at s and if no PAC-mite with more teeth also
aims at s.
(6) Barriers stay fixed, but blobs and PAC-mites change deterministically
in discrete units of time; the state of the universe at time t+1
is a function of its state at time t . Moreover, this transition
function is local: each site s changes in a manner that depends
only on its current contents and on the PAC-mites that attack it,
together with the contents of the site aimed at by its current PAC-mite,
if any. (A complete definition of the transition function appears
below.)
(7) The number of teeth in a PAC-mite corresponds to its age:
Toothless ones have just been born, but a triple-toothed mite that exists
at time t arrived at time t-3.
(8) PAC-mites belong to different species, where each species is defined
by a sequence of fifty ``genes,'' denoted by the symbols
u↓l, v↓{el}, w↓k, x↓k, y↓{ek}, z↓{ek}, for 0≤k≤2 and 0≤e,l≤3.
Each gene is either 0, 1, 2, or 3; hence there are 4↑{50} possible species.
(9) The genes determine the exact laws of succession, as follows:
(a) A site containing a barrier at time t contains a barrier
at time t+1.
(b) A site s containing a blob at time t contains a blob also
at time t+1, unless there is a unique PAC-mite attacking s at time t.
In the latter case the site will contain a toothless PAC-mite of the
same species in direction e+u↓l, where the attacker has direction e
and has l teeth. Thus, the attacker's u↓l gene specifies the
orientation of the new-born mite that consumes the blob.
(c) A site s containing a k-toothed PAC-mite of direction d
at time t will normally contain a (k+1)-toothed PAC-mite of the same
species at time t+1, unless k=3, when it normally reverts to a blob.
If k<3, the direction of the (k+1)-toothed mite will be
d + w↓k, if the original mite aimed at a barrier;
d + x↓k, if the original mite aimed at a blob;
d + y↓{ek}, if the original mite aimed at a PAC-mite of the
same species and of direction d+e;
d + z↓{ek}, if the original mite aimed at a PAC-mite of a
different species and of direction d+e.
(d) However, the normal aging process described in (c) is overridden
if at least one PAC-mite of a different species is attacking site s.
If there are two or more attackers, with at least one of a different
species, site s will revert to a blob at time t+1. If there is a
unique attacker, and if it belongs to a different species, suppose
it has l teeth and direction d+e; then site s will hold a toothless
PAC-mite of direction d+e+v↓{el} at time t+1, having the attacker's
species.
These formal rules boil down to a few intuitive principles: A PAC-mite
aims at a neighboring site, and it can see whether that site contains a
barrier, a blob, or another mite; in the latter case, it can also
perceive the direction of the neighboring mite, and it can tell whether
its neighbor is friend or foe. The mite then grows another tooth, and
changes direction, based on all this information. Changes in direction
are relative; if all of PAC-land were rotated by 90 degrees, its entire
behavior would rotate by 90 degrees. Furthermore a PAC-mite tries to
propagate a new mite of the same species in the aimed-at site; the
direction of this new mite can depend on everything the old mite knows.
However, the new mite will be born only if the old mite is a unique
attacker, and only when there is a change of species at the site of
birth. When different attackers contend for the same site, the
competition is so fierce that nothing but a blob remains.
Examples: (i) PAC-mites A and B (and no others) aim at site s, but
A has more teeth. If site s contains a blob or a PAC-mite of some
species different from A, a new mite of A 's species will be born at s.
Simultaneously, A and B change direction and grow another tooth; or
A dies, if it already has three teeth; or they are consumed by some
mites attacking them. (ii) PAC-mites A, B, C, D all aim at site s;
A and B have three teeth, but C and D have 2 or fewer. Then site s
will not experience a birth at the next moment of time; furthermore, it will
revert to a blob unless it contains a PAC-mite E of the same species as
both A and B, where E has fewer than 3 teeth. (iii) Two adjacent
PAC-mites A and B of different species, attacking each other, might
cause new clones b and a to occupy the respective sites of A and B;
the newborns might be attacking each other too.
Program control etc.
The program allows the user to create new species of PAC-mites, put new
mites in PAC-LAND and remove old ones, and do input and output to various
kinds of files.
The program parses commands on a line by line basis: you are free to use
the line editor and nothing happens until you type carriage return. Unique
prefixes are accepted and multiple blanks count as one. All key words are
lower case and must be typed that way (except COMMENT has to be upper case).
If a command is mistyped, the program ignores it and prints and error message.
In the explainations below, # represents any character and material in
<angle brackets> is a description of what is to be typed at that point in the
command.
bye
exit
end
quit
All of these terminate the program gracefully, closing any statistics
file and returning the display to normal.
help
This command displays a list of commands along with terse descriptions.
This is the same list that is displayed when the program first starts up.
step <integer>
go
These commands perform PAC generations. The display is updated at the
end of each genration according to the current mode (see above). The
argument to step says how many generations to do (the default is 1). The go
command is exactly equivalent to "step 1000000". This causes the program to
run continuously. It can be interrupted, however, since if a line is typed
while one of these commands is being executed, the computation will stop
immediately.
speed <real number>
This limits the speed of subsequent "go" and "step" generations to
at most the given number of generations per a second. The program has
its own (often optimistic) view of how fast it can run based on the current
x size, y size, display mode, and system load average. The speed is
automatically set to this value whenever the x or y size is set, the display
mode or edge mode is changed, or a "clear" or "input.../tex" command is
done. In other words, the default is to go as fast as possible and
the program is likely to reset the speed this way without telling you.
COMMENT <multiple lines of ignored text>;
The purpose of this command is to ignore E directories in files. It
is allowed anywhere, however, just like any other command. Note that the
final semicolon must occur at the end of a line; internal semicolons are
ignored along with the rest of the text. Unlike all other commands, this
one is upper case (as in E directories).
Creating and destroying PAC-mites
define # <list of 50 genes>
The character # will be used to identify a new species having the genes
given. This character may be upper or lower case or any special character
except that the following are illegal: RTLB0123≡.{}\ If the species
identifier is the same as a previous one, then that definition is overwritten.
It is desirable to choose characters that are easy to distinguish so that text
mode output will be more readable.
The genes should be digits between 0 and 3 in the order given on page 2
line 47 of this file:
u0,..,u3,v00,..,v03,v10,..,v13,..,v33,w0,..,w2,x0,..,x2,y00,..,y32,z00,..z32.
Spaces are ignored in the list of genes. Every effort has been made to follow
the rules exactly as stated.
change #
This loads the line editor with a "define" command giving the current
definition of species #. For ease of readibility it puts spaces between
u3 and v00, v33 and w0, w2 and x0, x2 and y00, and y32 and z00.
place ≡ <list of x y pairs delimited by spaces>
place . <list of x y pairs delimited by spaces>
place #<direction><age> <list of x y pairs delimited by spaces>
These commands place barriers, blobs, and PAC-mites respectively at the
given coordinates. When read from a file this does not update the display
(see the description of the `input' command.)
The new object overwrites the previous contents of the cells where it is
placed. For the third option, # should be a species identifier character
used in a previous define command. The direction should be R, T, L, or B for
whether the new mite faces right, top, left, or bottom. The age should be a
digit between 0 and 3 indicating how many teeth the new mite is to have. If
more than one x y pair is given, then all the mites placed will have the same
direction and age. (If this is not desired, more than one place command must
be used.)
The cell in the lower right corner of the display has coordinates (1, 1)
and x increases to the right and y increases as you go up. In wall mode (see
below), the cell (1, 1) is the lowest, right-most cell not counting the
barriers around the edge.
clear
clear all
"clear" empties PAC-LAND without effecting the size of PAC-LAND, the
display mode (graphics/text), or the edge mode (wall/wrap). "clear all"
also undefines all the species. If a large number of different species are
defined, they become hard to distinguish visually even if most of the populations
are zero. It is now also possible to overwrite old definitions with the
"define" command.
x size <integer>
y size <integer>
These set the width and height of PAC-land. The sizes given do not include
the exta border of barriers created in wall mode (see below). The size is
limitied by the available space on the display. With the current settings
in text mode, x size ≤ 84 and y size ≤ 37; in graphics mode x size ≤ 63 and
y size ≤ 44.
You are not allowed to change the size unless PAC-LAND is empty. (Use
the clear command to achieve this.) Note that "x" and "y" are unique
abbreviations, so the word "size" is optional.
Display control
wall mode
wrap mode
In wall mode, PAC-LAND is has a border of barriers around it, and in
wrap mode there is wrap-around from bottom to top and from left to right
so that PAC-LAND is topologically a torus. In wall mode the border of
barriers is displayed if there is room. Switching between wall mode and
wrap mode is allowed any time: there is no need to say "clear" first.
Note that "wa" and "wr" are unique abbreviations and the word "mode" is
optional.
text mode
graphics mode
In graphics mode, the display shows pictures of PAC-mites and in text
mode, the species identfier characters are used. The graphics display
allows the species and direction to be distinguished, but not the number
of teeth.
Since characters have a non-square aspect ratio, the text display is
taller and narrower than the graphics display. This puts a restriction
on when it is possible to change the display mode, but this is always
allowed as long as there is space (see description of x size and y size
commands above).
The display also includes a line at the bottom giving the generation
number followed by the population of each species. The format is
<genration no.> <pop. of spec 1><identifier for species 1> <same for 2> ...
In graphics mode a sample of each species is shown to the right of its
identifier character. This shows what markings the program is using
for each species.
"te" and "gr" are unique abbreviations and the word "mode" is optional.
sample rate <positive integer>
This causes susequent "step" and "go" commands to only update the
display once every n generations where n is the argument. The display
is not necessarily up to date when the "step" or "go" halts or is interrupted,
so it is wise to give a "redraw" command at this point.
If the argument is n, then the display is updated at the end of the first
generation and at the end of every nth susequent generation. This means that
if the sample rate is 10, then "step 20" will terminate with generation 11
still being displayed, but "step 21" will display generation 21.
If no argument is given, then this command prints the current sample rate.
redraw
Redraw the screen. (can be abbreviated `r')
Input and output
output <file name>/char
output <file name>/tex
output <file name>
These do one of two forms of output (the default is /char). (The
switches can be abbreviated.)
Both forms of output are ordinary files giving a picture of PAC-land
and the settings of the display mode, edge mode, etc. /char files are
meant to be read on-line and they show PAC-LAND very much as it appears
on the display in text mode.
/tex files give the age and direction of all the PAC-mites as well
as their species'. They can be TeXed and printed on the dover by saying
"tex <file name>" to the moniter. (If the file has no extension,
this must be stated explicitly by putting a "." after it.) It is also
possible to read a /tex file back in (see the "input" command below).
input <file name>/commands
input <file name>/tex
input <file name>
These do one of two modes of input (the default is /commands). (The
switches can be abbreviated.)
The /commands form causes subsequent commands to be read from a file.
If you type a line before this has been completely read, you will be given
the option of either aborting the input and taking subsequent commands from
the terminal or resuming reading the file. Input commands are even allowed
in a file. All comands work the same from a file as they do from the
terminal except the "place" command which does not update the display.
(There could be a large number of "place" commands in one file.)
The /tex form of input reads in a file that was created with the
/tex output command. The entire state of PAC-LAND is read off the file.
This includes the definitions of all species, the x and y size, the
display mode and edge mode, and the generation number. This is only
allowed when PAC-LAND is empty (see the description of clear). It is
possible to edit a /tex file and read it back in again but this must
be done very carefully. If anything unexpected is found in the file,
the program gives an error message and aborts the input
statistics <file name>
no statistics
After giving a "statistics" command, subsequent "step" and "go"
go commands will cause information to be sent to <file name>. There will
be one line in the file for each new generation that is computed. Each
line gives the generation number and the population of each species
as it is displayed below the picture of PAC-LAND. At the end of the
file, the CURRENT definitions of all the species are given along with all
the auxiliary information produced by the "output" command.
The "no statistics" command closes this file. This may be abreviated
simply by "n". The auxiliary information at the end of the file will be what
is in effect when this command is given (or at the "bye", "end", "exit", or
"quit" command if that comes first).